package com.sunlands.qdcy.tongzhuo.repository;

import com.sunlands.qdcy.tongzhuo.model.UserDiaryTopicAttentionDO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author shixiaopeng
 */

@Repository
public interface UserDiaryTopicAttentionRepository extends JpaRepository<UserDiaryTopicAttentionDO, Long>, JpaSpecificationExecutor<UserDiaryTopicAttentionDO> {

    List<UserDiaryTopicAttentionDO> findByUserId(long userId);

    UserDiaryTopicAttentionDO findByUserIdAndTopicAndIsAttention(long userId, String topic, Boolean isAttention);

    Long countByTopicAndIsAttention(String topic, Boolean isAttention);

    Page<UserDiaryTopicAttentionDO> findAllByUserIdAndIsAttentionOrderByUpdateTimeDesc(Long userId, Boolean isAttention, Pageable pageable);
}
